﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using YasharEl.Infrastructure.EntityModel;
using YasharEl.Infrastructure.TaskEngine.EntityModel.Metadata;

namespace YasharEl.Infrastructure.TaskEngine.EntityModel
{
    [MetadataType(typeof(TaskActionEntityMetadata))]
    public class TaskActionEntity : Entity, ITaskAction
    {
        #region Fields

        private string _actionMessageType;

        #endregion

        #region ITaskAction Members

        public virtual long TaskActionId { get; private set; }
        public virtual string ActionName { get; set; }
        public virtual bool IsSelected { get; set; }
        public virtual DateTime CreatedDate { get; set; }
        public virtual DateTime? ModifiedDate { get; set; }
        public virtual ITask Task { get; set; }
        public virtual string DisplayName { get; set; }

        public virtual Type ActionMessageType
        {
            get
            {
                return Type.GetType(_actionMessageType);
            }
            set
            {
                _actionMessageType = value.AssemblyQualifiedName;
            }
        }

        public virtual ITaskParticipant ModifiedBy
        {
            get;
            set;
        }

        public virtual ITaskParticipant CreatedBy
        {
            get;
            set;
        }

        #endregion

        #region IEntity Implementation

        public override long Id
        {
            get
            {
                return TaskActionId;
            }
            protected set
            {
                TaskActionId = value;
            }
        }

        #endregion
    }
}
